import 'package:boss/ui/page/forgetPassword/provider/forget_password_provider.dart';
import 'package:boss/ui/widget/form/base_text_form_field.dart';
import 'package:boss/ui/widget/form/phone_code_form_field.dart';

import 'package:hi_common/hi_common.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:provider/provider.dart';

class ForgetPasswordForm extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Container(
      padding: EdgeInsets.symmetric(
        horizontal: 65.w,
      ),
      margin: EdgeInsets.only(
        top: ScreenUtil.instance.setHeight(45.5),
      ),
      child: Column(
        children: <Widget>[
          BaseTextFormField(
            hintText: '请输入你的手机号',
            textAlign: TextAlign.start,
            keyboardType: TextInputType.number,
            inputFormatters: [
              FilteringTextInputFormatter.allow(RegUtil.numberReg)
            ],
            isClearAll: true,
            onChanged: (value) {
              var forgetPasswordProvider = Provider.of<ForgetPasswordProvider>(
                context,
                listen: false,
              );
              forgetPasswordProvider.setPhone(value);
            },
          ),
          Consumer<ForgetPasswordProvider>(
            builder: (context, forgetPasswordProvider, child) {
              return PhoneCodeFormField(
                codeType: CodeType.updatePassword,
                phone: forgetPasswordProvider.phone,
                onChanged: (value) {
                  forgetPasswordProvider.setCode(value);
                },
              );
            },
          ),
          BaseTextFormField(
            hintText: '请输入6-16位含数字字母密码',
            textAlign: TextAlign.start,
            obscureText: true,
            onChanged: (value) {
              var forgetPasswordProvider = Provider.of<ForgetPasswordProvider>(
                context,
                listen: false,
              );
              forgetPasswordProvider.setPassword(value);
            },
          ),
        ],
      ),
    );
  }
}
